package la.iok.hzsvn.lewin.movie.shopmovie.entity;

import la.iok.hzsvn.share.collection.IdAble;

import java.util.Date;
import java.util.Objects;

/**
 * 拼车
 */
public class Carpool implements IdAble<Long> {
    /**
     * 拼车中状态
     */
    public static final Integer STATUS_PREPARE = 1;
    /**
     * 游戏中状态/已发车状态
     */
    public static final Integer STATUS_GAMING = 2;
    /**
     * 已经结束状态
     */
    public static final Integer STATUS_ENDED = 3;
    private Long id;
    /**
     * 拼车店铺
     */
    private Long orgUnitId;
    /**
     * 车次标题
     */
    private String title;
    /**
     * 店铺剧本id
     */
    private Long shopMovieId;
    /**
     * 标签数组.预计的剧本标签，选择了剧本的情况下,以剧本的标签为准
     */
    private String tag;
    /**
     * 玩家数量,预计的玩家数量。选择了剧本的情况下,以剧本的玩家数量[最大玩家数量]为准
     */
    private Integer playerCount;

    private Integer minPlayerCount;
    /**
     * 约车时间
     */
    private Date startTime;
    /**
     * 状态。1：拼车中；2：已发车。
     * 拼车中的状态，可以扫描拼车二维码加入拼车；
     * 已发车表示当前已经发车，玩家正在进行游戏，此时不能加入拼车；
     */
    private Integer status;
    /**
     * 数据版本,并发控制
     */
    private Long version;
    /**
     * 发车时间
     */
    private Date beginTime;
    /**
     * 发车的用户id(DM的id)
     */
    private Long beginnerId;
    /**
     * 结束时间
     */
    private Date terminateTime;
    /**
     * 结束者的用户id.如果是系统自动结束,则值为-1
     */
    private Long terminatorId;
    /**
     * 确认人。对拼车的有效性进行确认
     */
    private Long confirmorId;
    /**
     * 确认时间
     */
    private Date confirmTime;

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getOrgUnitId() {
        return orgUnitId;
    }

    public void setOrgUnitId(Long orgUnitId) {
        this.orgUnitId = orgUnitId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getShopMovieId() {
        return shopMovieId;
    }

    public void setShopMovieId(Long shopMovieId) {
        this.shopMovieId = shopMovieId;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public Integer getPlayerCount() {
        return playerCount;
    }

    public void setPlayerCount(Integer playerCount) {
        this.playerCount = playerCount;
    }

    public Integer getMinPlayerCount() {
        return minPlayerCount;
    }

    public void setMinPlayerCount(Integer minPlayerCount) {
        this.minPlayerCount = minPlayerCount;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Long getBeginnerId() {
        return beginnerId;
    }

    public void setBeginnerId(Long beginnerId) {
        this.beginnerId = beginnerId;
    }

    public Date getTerminateTime() {
        return terminateTime;
    }

    public void setTerminateTime(Date terminateTime) {
        this.terminateTime = terminateTime;
    }

    public Long getTerminatorId() {
        return terminatorId;
    }

    public void setTerminatorId(Long terminatorId) {
        this.terminatorId = terminatorId;
    }

    public Long getConfirmorId() {
        return confirmorId;
    }

    public void setConfirmorId(Long confirmorId) {
        this.confirmorId = confirmorId;
    }

    public Date getConfirmTime() {
        return confirmTime;
    }

    public void setConfirmTime(Date confirmTime) {
        this.confirmTime = confirmTime;
    }

    /**
     * 当前是否为结束状态
     * @return 是结束状态返回true,否则false
     */
    public boolean ended(){
        return STATUS_ENDED.equals(status);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Carpool)) return false;
        Carpool carpool = (Carpool) o;
        return Objects.equals(id, carpool.id) && Objects.equals(orgUnitId, carpool.orgUnitId) && Objects.equals(title, carpool.title) && Objects.equals(shopMovieId, carpool.shopMovieId) && Objects.equals(tag, carpool.tag) && Objects.equals(playerCount, carpool.playerCount) && Objects.equals(startTime, carpool.startTime) && Objects.equals(status, carpool.status) && Objects.equals(version, carpool.version) && Objects.equals(beginTime, carpool.beginTime) && Objects.equals(beginnerId, carpool.beginnerId) && Objects.equals(terminateTime, carpool.terminateTime) && Objects.equals(terminatorId, carpool.terminatorId) && Objects.equals(confirmorId, carpool.confirmorId) && Objects.equals(confirmTime, carpool.confirmTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, orgUnitId, title, shopMovieId, tag, playerCount, startTime, status, version, beginTime, beginnerId, terminateTime, terminatorId, confirmorId, confirmTime);
    }
}
